﻿using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Web;
using System.Web.Script.Serialization;
using System.Web.UI;
using System.Web.UI.WebControls;
using WebApplication2.Class;

namespace WebApplication2
{
    public partial class Preparatory : System.Web.UI.Page
    {
        int language = 0;
        protected void Page_Load(object sender, EventArgs e)
        {
            language = (int)Session["Language"];
            GetFormLabel();
            GetFormData();
        }

        public void GetFormLabel()
        {
            WebRequest req = WebRequest.Create("http://192.168.1.156/api/FMTXPreparatoryLabel?LanguageID=" + language);
            req.ContentType = "application/json";
            WebResponse resp = req.GetResponse();
            Stream stream = resp.GetResponseStream();
            StreamReader re = new StreamReader(stream);
            String json = re.ReadToEnd();
            // json = "{\"FMTXPreHDLabel\":" + json + "}";
            JavaScriptSerializer ser = new JavaScriptSerializer();
            List<FMTXPreparatoryLabel> keysWrapper = Newtonsoft.Json.JsonConvert.DeserializeObject<List<FMTXPreparatoryLabel>>(json);
            //   JavaScriptSerializer ser = new JavaScriptSerializer();
            // var keysWrapper = Newtonsoft.Json.JsonConvert.DeserializeObject<KeyWrapperPreHDLabel>(json);
            foreach (var item in keysWrapper)
            {
                if (item.FormLabelCode == "Tx-Sc2-GpPrep")
                {
                    lblPreparatory.Text = item.Language.ToString();
                }
                if (item.FormLabelCode == "Tx-Sc2-Chair")
                {
                    lblStation.Text = item.Language.ToString();
                }
                if (item.FormLabelCode == "Tx-Sc2-ROW")
                {
                    lblRO.Text = item.Language.ToString();
                }
                if (item.FormLabelCode == "Tx-Sc2-MID")
                {
                    lblMachineID.Text = item.Language.ToString();
                }
                if (item.FormLabelCode == "Tx-Sc2-Mtype")
                {
                    lblType.Text = item.Language.ToString();
                }
                if (item.FormLabelCode == "Tx-Sc2-Sched")
                {
                    lblSchedule.Text = item.Language.ToString();
                }
                if (item.FormLabelCode == "Tx-Sc2-Shift")
                {
                    lblshift.Text = item.Language.ToString();
                }
                if (item.FormLabelCode == "Tx-Sc2-Dialyser")
                {
                    lblDialyser.Text = item.Language.ToString();
                }
                if (item.FormLabelCode == "Tx-Sc2-Useno")
                {
                    lbluseno.Text = item.Language.ToString();
                }
                if (item.FormLabelCode == "Tx-Sc2-Max")
                {
                    Max.Text = item.Language.ToString();
                }
                if (item.FormLabelCode == "Tx-Sc2-Dialysate")
                {
                    lbldialysate.Text = item.Language.ToString();
                }
                if (item.FormLabelCode == "Tx-Sc2-Aconc")
                {
                    lblConA.Text = item.Language.ToString();
                }
                if (item.FormLabelCode == "Tx-Sc2-Bconc")
                {
                    lblConB.Text = item.Language.ToString();
                }
                if (item.FormLabelCode == "Tx-Sc2-Qd")
                {
                    lblFlow.Text = item.Language.ToString();
                }
                if (item.FormLabelCode == "Tx-Sc2-Cflow")
                {
                    lblCounterflow.Text = item.Language.ToString();
                }
                if (item.FormLabelCode == "Tx-Sc2-Cflowyes")
                {
                    lblCouterYes.Text = item.Language.ToString();
                }
                if (item.FormLabelCode == "Tx-Sc2-Cflowno")
                {
                    lblCouterNo.Text = item.Language.ToString();
                }
                if (item.FormLabelCode == "Tx-Sc2-Dtemp")
                {
                    lblTemperature.Text = item.Language.ToString();
                }
                if (item.FormLabelCode == "Tx-Sc2-Cond")
                {
                    lblCondu.Text = item.Language.ToString();
                }
                if (item.FormLabelCode == "Tx-Sc2-pH")
                {
                    lblPH.Text = item.Language.ToString();
                }
                if (item.FormLabelCode == "Tx-Sc2-GpAC")
                {
                    lblAntocoa.Text = item.Language.ToString();
                }
                if (item.FormLabelCode == "Tx-Sc2-Atype")
                {
                    lblAntiType.Text = item.Language.ToString();
                }
                if (item.FormLabelCode == "Tx-Sc2-Primeyes")
                {
                    lblTypeYes.Text = item.Language.ToString();
                }
                if (item.FormLabelCode == "Tx-Sc2-Primeno")
                {
                    lblTypeNo.Text = item.Language.ToString();
                }
                if (item.FormLabelCode == "Tx-Sc2-Bolus")
                {
                    lblBolus.Text = item.Language.ToString();
                }
                if (item.FormLabelCode == "Tx-Sc2-Mdose")
                {
                    lblMiddose.Text = item.Language.ToString();
                }
                if (item.FormLabelCode == "Tx-Sc2-Load")
                {
                    lblLoad.Text = item.Language.ToString();
                }
                if (item.FormLabelCode == "Tx-Sc2-Prepared")
                {
                    lblPreparedby.Text = item.Language.ToString();
                }
                if (item.FormLabelCode == "Tx-Sc2-Given")
                {
                    lblGivenby.Text = item.Language.ToString();
                }
                if (item.FormLabelCode == "Tx-Sc2-Atime")
                {
                    lbltime.Text = item.Language.ToString();
                }
                if (item.FormLabelCode == "Tx-Sc2-infusion")
                {
                    lblInfusion.Text = item.Language.ToString();
                }
                if (item.FormLabelCode == "Tx-Sc2-infurate")
                {
                    lblInfusionUnit.Text = item.Language.ToString();
                }
                if (item.FormLabelCode == "Tx-Sc2-Timeoff")
                {
                    lblTimeOff.Text = item.Language.ToString();
                }
                if (item.FormLabelCode == "Tx-Sc2-Timemin")
                {
                    lbltimeoffUnit.Text = item.Language.ToString();
                }
                if (item.FormLabelCode == "Tx-Sc2-GpRQC")
                {
                    lblReprocQC.Text = item.Language.ToString();
                }
                if (item.FormLabelCode == "Tx-Sc2-PreProcess")
                {
                    lblPreprocess.Text = item.Language.ToString();
                }
                if (item.FormLabelCode == "Tx-Sc2-PreTx")
                {
                    lblTreatment.Text = item.Language.ToString();
                }
                if (item.FormLabelCode == "Tx-Sc2-Rtech")
                {
                    lblReuse.Text = item.Language.ToString();
                }
                if (item.FormLabelCode == "Tx-Sc2-ATCby")
                {
                    lblCheckby.Text = item.Language.ToString();
                }
                if (item.FormLabelCode == "Tx-Sc2-Alarm")
                {
                    lblAlarmTest.Text = item.Language.ToString();
                }
                if (item.FormLabelCode == "Tx-Sc2-ATPass")
                {
                    lblPass.Text = item.Language.ToString();
                }
                if (item.FormLabelCode == "Tx-Sc2-Dpress")
                {
                    lblPressure.Text = item.Language.ToString();
                }
                if (item.FormLabelCode == "Tx-Sc2-DPTPass")
                {
                    lblPresPass.Text = item.Language.ToString();
                }
                if (item.FormLabelCode == "Tx-Sc2-Mproc")
                {
                    lblManual.Text = item.Language.ToString();
                }
                if (item.FormLabelCode == "Tx-Sc2-match")
                {
                    lblCorrect.Text = item.Language.ToString();
                }
                if (item.FormLabelCode == "Tx-Sc2-witness")
                {
                    lblWitenessBy.Text = item.Language.ToString();
                }
                if(item.FormLabelCode == "Tx-Sc2-GpDC")
                {
                    lblDialyserSetUp.Text = item.Language.ToString();
                }
                if (item.FormLabelCode == "Tx-Sc2-DPR")
                {
                    lblPrior.Text = item.Language.ToString();
                }
                if (item.FormLabelCode == "Tx-Sc2-DPRpos")
                {
                    lblPositive.Text= item.Language.ToString();
                }
                if (item.FormLabelCode == "Tx-Sc2-DPRpos")
                {
                    lblPositive.Text = item.Language.ToString();
                }
                if (item.FormLabelCode == "Tx-Sc2-SCheckCby")
                {
                    lblCheckby.Text = item.Language.ToString();
                }
                if (item.FormLabelCode == "Tx-Sc2-RDT")
                {
                    lblResidualTest.Text = item.Language.ToString();
                }
                if (item.FormLabelCode == "Tx-Sc2-RDTD")
                {
                    lblDialyserN.Text = item.Language.ToString();
                }
                if (item.FormLabelCode == "Tx-Sc2-RDTDneg")
                {
                    tbxDialyNegative.Text = item.Language.ToString();
                }
                if (item.FormLabelCode == "Tx-Sc2-RDTM")
                {
                    lblMachine.Text= item.Language.ToString();
                }
                if (item.FormLabelCode == "Tx-Sc2-RDTMNa")
                {
                   lblNA.Text = item.Language.ToString();
                }
                if (item.FormLabelCode == "Tx-Sc2-RDTMNeg")
                {
                    lblNegative2.Text= item.Language.ToString();
                }
                if (item.FormLabelCode == "Tx-Sc2-RDTB")
                {
                   lblBloodline.Text= item.Language.ToString();
                }
                if (item.FormLabelCode == "Tx-Sc2-RDTBNeg")
                {
                    lblNegative3.Text = item.Language.ToString();
                }
                if (item.FormLabelCode == "Tx-Sc2-RDTS")
                {
                    lblsalinebag.Text = item.Language.ToString();
                }
                if (item.FormLabelCode == "Tx-Sc2-RDTSNeg")
                {
                  lblNegative4.Text= item.Language.ToString();
                }
                if (item.FormLabelCode == "Tx-Sc2-Start")
                {
                    lblStartTime.Text = item.Language.ToString();
                }
                if (item.FormLabelCode == "Tx-Sc2-primeby")
                {
                    lblPrimeby.Text = item.Language.ToString();
                }
                if (item.FormLabelCode == "Tx-Sc2-dialyby")
                {
                    lblCommenced.Text = item.Language.ToString();
                }
                if (item.FormLabelCode == "Tx-Sc2-Com")
                {
                    lblPrepComments.Text = item.Language.ToString();
                }
                if (item.FormLabelCode == "Tx-Sc2-Compby")
                {
                   lblComleteby.Text = item.Language.ToString();
                }
                if (item.FormLabelCode == "Tx-Sc2-Modby")
                {
                    lblModified.Text= item.Language.ToString();
                }
                if (item.FormLabelCode == "Tx-Sc2-GpRQC4")
                {
                    lblChange.Text = item.Language.ToString();
                }
                if (item.FormLabelCode == "Tx-Sc2-2MID")
                {
                   lbl2ndMachineID.Text = item.Language.ToString();
                }
                if (item.FormLabelCode == "Tx-Sc2-mtime")
                {
                    lblTimeChanged.Text = item.Language.ToString();
                }
                if (item.FormLabelCode == "Tx-Sc2-mhhmm")
                {
                    lblhhmm.Text = item.Language.ToString();
                }
                if (item.FormLabelCode == "Tx-Sc2-2Dialyser")
                {
                    lbl2ndDialyser.Text = item.Language.ToString();
                }
                if (item.FormLabelCode == "Tx-Sc2-dtime")
                {
                    lblTimeChange2.Text = item.Language.ToString();
                }
                if (item.FormLabelCode == "Tx-Sc2-dhhmm")
                {
                   lblhhmm2.Text = item.Language.ToString();
                }
                if (item.FormLabelCode == "Tx-Sc2-reason")
                {
                    lblReasonChange.Text= item.Language.ToString();
                }
                if (item.FormLabelCode == "Tx-Sc2-change")
                {
                    lblChangeBy.Text = item.Language.ToString();
                }
                if (item.FormLabelCode == "Tx-Sc2-Schecks")
                {
                    lblsterilant.Text = item.Language.ToString();
                }
                if (item.ScheduleID != 0)
                {
                    ddlSchedule.Items.Add(item.Schedule_Frequency.ToString());
                }
                if (item.ShiftID != 0)
                {
                    ddlShift.Items.Add(item.Shift.ToString());
                }
                if (item.ChairID != 0)
                {
                    ddlstation.Items.Add(item.Chair_Name.ToString());
                }
                if (item.MachineID != 0)
                {
                    if (item.Machine_Language != "")
                    {
                        ddlMachineID.Items.Add(item.Machine_Language.ToString());
                    }
                }
                if (item.MachineID != 0)
                {
                    if (item.Machine_Language != "")
                    {
                        ddl2ndMachineID.Items.Add(item.Machine_Language.ToString());
                    }
                }
                if (item.DialyserID != 0)
                {
                    ddldialyser.Items.Add(item.Dialyser_Name.ToString());
                }
                if (item.DialyserID != 0)
                {
                    dd2ndDialyser.Items.Add(item.Dialyser_Name.ToString());
                }
                if (item.HepTypeID != 0)
                {
                    DropDownList3.Items.Add(item.HepLanguage.ToString());
                }
                if (item.HepTypeID != 0)
                {
                    ddlAntiType.Items.Add(item.HepLanguage.ToString());
                }
                if (item.User_Id != 0)
                {
                    if (item.Initials != "")
                    {
                        ddlChangeby.Items.Add(item.Initials.ToString());
                    }
                    
                }
                if (item.User_Id != 0)
                {
                    if (item.Initials != "")
                    {
                        ddlCommencedBy.Items.Add(item.Initials.ToString());
                    }
                }
                if (item.User_Id != 0)
                {
                    if (item.Initials != "")
                    {
                        ddlCompleteby.Items.Add(item.Initials.ToString());
                    }
                }
                if (item.User_Id != 0)
                {
                    if (item.Initials != "")
                    {
                        ddlModifiedBy.Items.Add(item.Initials.ToString());
                    }
                }
                if (item.User_Id != 0)
                {
                    if (item.Initials != "")
                    {
                        ddlalarmCheck.Items.Add(item.Initials.ToString());
                    }
                }
                if (item.User_Id != 0)
                {
                    if (item.Initials != "")
                    {
                        ddlManualCheck.Items.Add(item.Initials.ToString());
                    }
                }
                if (item.User_Id != 0)
                {
                    if (item.Initials != "")
                    {
                        ddlNegative2Check.Items.Add(item.Initials.ToString());
                    }
                }
                if (item.User_Id != 0)
                {
                    if (item.Initials != "")
                    {
                        ddlNegative3Check.Items.Add(item.Initials.ToString());
                    }
                }
                if (item.User_Id != 0)
                {
                    if (item.Initials != "")
                    {
                        ddlNegativeCheck.Items.Add(item.Initials.ToString());
                    }
                }
                if (item.User_Id != 0)
                {
                    if (item.Initials != "")
                    {
                        ddlPositiveCheckby.Items.Add(item.Initials.ToString());
                    }
                }
                if (item.User_Id != 0)
                {
                    if (item.Initials != "")
                    {
                        ddlpressureCheckby.Items.Add(item.Initials.ToString());
                    }
                }
                if (item.User_Id != 0)
                {
                    if (item.Initials != "")
                    {
                        ddlprimedby.Items.Add(item.Initials.ToString());
                    }
                }
                if (item.User_Id != 0)
                {
                    if (item.Initials != "")
                    {
                        ddlSalineNegativeCheck.Items.Add(item.Initials.ToString());
                    }
                }
                if (item.User_Id != 0)
                {
                    if (item.Initials != "")
                    {
                        ddlWitessnessby.Items.Add(item.Initials.ToString());
                    }
                }
                if (item.ReasonID != 0)
                {
                    ddlReasonForchange.Items.Add(item.Reason_Language.ToString());
                }
                if (item.User_Id != 0)
                {
                    if (item.Initials != "")
                    {
                        ddlpreparebybou.Items.Add(item.Initials.ToString());
                    }
                }
                if (item.User_Id != 0)
                {
                    if (item.Initials != "")
                    {
                        ddlpreparebyMid.Items.Add(item.Initials.ToString());
                    }
                }
                if (item.User_Id != 0)
                {
                    if (item.Initials != "")
                    {
                        ddlwitessblous.Items.Add(item.Initials.ToString());
                    }
                }
                if (item.User_Id != 0)
                {
                    if (item.Initials != "")
                    {
                        ddlwitenessMid.Items.Add(item.Initials.ToString());
                    }
                }
                if (item.User_Id != 0)
                {
                    if (item.Initials != "")
                    {
                        ddlGivenByBolu.Items.Add(item.Initials.ToString());
                    }
                }
                if (item.User_Id != 0)
                {
                    if (item.Initials != "")
                    {
                        ddlGivenByMid.Items.Add(item.Initials.ToString());
                    }
                }
                if (item.DialysateID != 0)
                {
                    ddldialysate.Items.Add(item.Dialysate_Name.ToString());
                }
                if (item.User_Id != 0)
                {
                    if (item.Initials != "")
                    {
                        ddlCorrect.Items.Add(item.Initials.ToString());
                    }
                }
            }
        }

        public void GetFormData()
        {
            int HDTreatmentID = 177;
            WebRequest req = WebRequest.Create("http://192.168.1.156/api/FMTXPreparatory?HDTreatmentID=" + HDTreatmentID);
            req.ContentType = "application/json";
            WebResponse resp = req.GetResponse();
            Stream stream = resp.GetResponseStream();
            StreamReader re = new StreamReader(stream);
            String json = re.ReadToEnd();

            JavaScriptSerializer ser = new JavaScriptSerializer();
            //  PreHD keysWrapper = Newtonsoft.Json.JsonConvert.DeserializeObject<PreHD>(json);
            //  var keysWrapper = Newtonsoft.Json.JsonConvert.DeserializeObject<KeyWrapperPreHD>(json);
            // object obje = ser.Deserialize<PreHD>(json);

            var obj = JObject.Parse(json);
            tbxRO.Text = (obj["ROWater"]).ToString();
            tbxuseno.Text = (obj["UseNo"]).ToString();
            tbxmax.Text = (obj["Dialyser_ReuseNo"]).ToString();

            tbxconA.Text = (obj["DialysateAconc"]).ToString();
            tbxConB.Text = (obj["DialysateBconc"]).ToString();
            tbxflow.Text  = (obj["Dialysis_Flow"]).ToString();
            tbxTemperature.Text = (obj["Dialysate_Temp"]).ToString();
            tbxPH.Text = (obj["Dialysate_PH"]).ToString();
            tbxcondu.Text = (obj["Conductivity"]).ToString();
            tbxload.Text = (obj["Actual_Heparin_bolus"]).ToString();
            tbxloadmid.Text = (obj["Heparine_Mid_Dose"]).ToString();

            if (Convert.ToDateTime(obj["HD_Run_Bolus_Time"]) != DateTime.MinValue)
            {
                tbxtime.Text = (obj["HD_Run_Bolus_Time"]).ToString();
            }
            if (Convert.ToDateTime(obj["HD_Run_MidDose_Time"]) != DateTime.MinValue)
            {
                tbxtimeMid.Text = (obj["HD_Run_MidDose_Time"]).ToString(); 
             
            }
            //if ((obj["HD_Run_Start_time2"]) == DBNull.Value)
            //{
            //    tbxStartTime.Text = Convert.ToDateTime(obj["HD_Run_Start_time2"]).ToString("HH:mm");
            //}
            if (Convert.ToDateTime(obj["Complete_DateTime"]) != DateTime.MinValue)
            {
                CompleteDate.Value = (obj["Complete_DateTime"]).ToString();
            }
            if (Convert.ToDateTime(obj["Modified_DateTime"]) != DateTime.MinValue)
            {
               ModifiedDate.Value = (obj["Modified_DateTime"]).ToString();
            }
            if (Convert.ToDateTime(obj["Time_Changed_Machine"]) != DateTime.MinValue)
            {
                tbxTimeChange.Text = (obj["Time_Changed_Machine"]).ToString();
            }
            if (Convert.ToDateTime(obj["Time_Changed_dialyser"]) != DateTime.MinValue)
            {
                tbxTimeChange2.Text = (obj["Time_Changed_dialyser"]).ToString();
            }

            tbxprepComments.Text = (obj["HDMac_Comments"]).ToString();

            //checkboxes

           // cbCFYes

            if ((obj["Counter_Flow"]).ToString() == "Yes")
            {
                cbCFYes.Checked = true;
            }
          //   cbCFNo
            if (obj["Counter_Flow"].ToString() == "No")
            {
                cbCFNo.Checked = true;
            }
           // cbpreprocess

            if (obj["IsDialyserPreProcess"].ToString() == "True")
            {
                cbpreprocess.Checked = true;
            }

            //cbtreatment
            if (obj["IsDialyserPreTreat"].ToString() == "True")
            {
                cbtreatment.Checked = true;
            }
            //cbAlarmTest
            if (obj["Alarm_Tests"].ToString() == "Pass")
            {
                cbAlarmTest.Checked = true;
            }
            //cbPressure
            if (obj["Dialyser_Pressure_Test"].ToString() == "Pass")
            {
                cbPressure.Checked = true;
            }

            //cbTypeYes
            if (obj["IsPrime"].ToString() == "True")
            {
                cbTypeYes.Checked = true;
            }
            //cbTypeNo
            if (obj["IsPrime"].ToString() == "False")
            {
                cbTypeNo.Checked = true;
            }
            //cbPriprPositive
            if (obj["Disinfectant_Prior_To_Rinse"].ToString() == "Positive")
            {
                cbPriprPositive.Checked = true;
            }
            //cbNegative1
            if (obj["Residual_Disinfectant_Test"].ToString() == "Negative")
            {
                cbNegative1.Checked = true;
            }
            //cbMachineNA
            if (obj["Residual_Machine_Test"].ToString() == "")
            {
                cbMachineNA.Checked = true;
            }
            //cbNegative2

            if (obj["Residual_Machine_Test"].ToString() == "Negative")
            {
                cbNegative2.Checked = true;
            }
            //cbNegativeBlood
            if (obj["Residual_Bloodline_Test"].ToString() == "Negative")
            {
                cbNegativeBlood.Checked = true;
            }

            //cbsalineNegative
            if (obj["Residual_SalineBag_Test"].ToString() == "Negative")
            {
                cbsalineNegative.Checked = true;
            }

            //cbcompleteby



            //DropDownList
            WebRequest req1 = WebRequest.Create("http://192.168.1.156/api/FMTXPreparatoryLabel?LanguageID=" + language);
            req1.ContentType = "application/json";
            WebResponse resp1 = req1.GetResponse();
            Stream stream1 = resp1.GetResponseStream();
            StreamReader re1 = new StreamReader(stream1);
            String json1 = re1.ReadToEnd();
            // json = "{\"FMTXPreHDLabel\":" + json + "}";
            JavaScriptSerializer ser1 = new JavaScriptSerializer();
            List<FMTXPreparatoryLabel> keysWrapper = Newtonsoft.Json.JsonConvert.DeserializeObject<List<FMTXPreparatoryLabel>>(json1);

            int stationID = Convert.ToInt32(obj["Chair"]);
            int MachineID = Convert.ToInt32(obj["MachineCode"]);
            int type = Convert.ToInt32(obj["Machine_Type"]);
            int schedule = Convert.ToInt32(obj["Schedule"]);
            int Shift = Convert.ToInt32(obj["Shift"]);
            int Dialyser = Convert.ToInt32(obj["First_Dialyser"]);
            int Dialysate = Convert.ToInt32(obj["First_Dialysate"]);
            int reuse = Convert.ToInt32(obj["Reuse_Tech"]);
            int AlarmTest = Convert.ToInt32(obj["AlarmTest_CheckBy"]);
            int pressureTest = Convert.ToInt32(obj["DPTTest_CheckBy"]);
            int mannual = Convert.ToInt32(obj["MP_CheckBy"]);
            int antiType = Convert.ToInt32(obj["HeparineTyp"]);
            int preparaby = Convert.ToInt32(obj["Bolus_Prepared_By"]);
            int preparabyMin = Convert.ToInt32(obj["MidDose_Prepared_By"]);
            int givenby = Convert.ToInt32(obj["Bolus_Administered_By"]);
            int givebyMid = Convert.ToInt32(obj["MidDose_Administered_By"]);
            int witnessby = Convert.ToInt32(obj["Bolus_Witnessed_By"]);
            int witnessbyMid = Convert.ToInt32(obj["MidDose_Witnessed_By"]);
            int CorrectDia = Convert.ToInt32(obj["Dialyser_Patient_ID_Match"]);
            int witnessbyDia = Convert.ToInt32(obj["DialyserCheck_WitnessBy"]);
            int PriorToR = Convert.ToInt32(obj["DPR_CheckBy"]);
            int DialyserCheck = Convert.ToInt32(obj["RDT_CheckBy"]);
            int machinecheck = Convert.ToInt32(obj["Residual_Machine_CheckedBy"]);
            int bloodline = Convert.ToInt32(obj["Residual_Bloodline_CheckedBy"]);
            int saline = Convert.ToInt32(obj["Residual_SalineBag_CheckedBy"]);
            int primeBy = Convert.ToInt32(obj["PrimedBy"]);
            int Commencedby = Convert.ToInt32(obj["DialysedBy"]);
            int completeby = Convert.ToInt32(obj["Completed_By"]);
            int Modifiedby = Convert.ToInt32(obj["Modified_By"]);
            int Secndmachine = Convert.ToInt32(obj["Second_Machine_ID"]);
            int SecndDialyser = Convert.ToInt32(obj["Second_Dialyser"]);
            int reasonChange = Convert.ToInt32(obj["ReasonForChanged"]);
            int ChangeBy = Convert.ToInt32(obj["ChagedBy"]);


            foreach (var item in keysWrapper)
            {
                if (item.User_Id != 0)
                {
                    if (item.User_Id == reuse)
                    {
                        ddlReuse.Text = item.Initials.ToString();
                    }
                    if (item.User_Id == AlarmTest)
                    {
                        ddlalarmCheck.Text = item.Initials.ToString();
                    }
                    if (item.User_Id == pressureTest)
                    {
                        ddlpressureCheckby.Text = item.Initials.ToString();
                    }
                    if (item.User_Id == mannual)
                    {
                        ddlManualCheck.Text = item.Initials.ToString();
                    }
                    if (item.User_Id == preparaby)
                    {
                        ddlpreparebybou.Text = item.Initials.ToString();
                    }
                    if (item.User_Id == preparabyMin)
                    {
                        ddlpreparebyMid.Text = item.Initials.ToString();
                    }
                    if (item.User_Id == givenby)
                    {
                        ddlGivenByBolu.Text = item.Initials.ToString();
                    }
                    if (item.User_Id == givebyMid)
                    {
                        ddlGivenByMid.Text = item.Initials.ToString();
                    }
                    if (item.User_Id == witnessby)
                    {
                        ddlwitessblous.Text = item.Initials.ToString();
                    }
                    if (item.User_Id == witnessbyMid)
                    {
                        ddlwitenessMid.Text = item.Initials.ToString();
                    }
                    if (item.User_Id == CorrectDia)
                    {
                        ddlCorrect.Text = item.Initials.ToString();
                    }
                    if (item.User_Id == PriorToR)
                    {
                        ddlPositiveCheckby.Text = item.Initials.ToString();
                    }
                    if (item.User_Id == witnessbyDia)
                    {
                        ddlWitessnessby.Text = item.Initials.ToString();
                    }
                    if (item.User_Id == DialyserCheck)
                    {
                        ddlNegativeCheck.Text = item.Initials.ToString();
                    }
                    if (item.User_Id == machinecheck)
                    {
                        ddlNegative2Check.Text = item.Initials.ToString();
                    }
                    if (item.User_Id == bloodline)
                    {
                        ddlNegative3Check.Text = item.Initials.ToString();
                    }
                    if (item.User_Id == saline)
                    {
                        ddlSalineNegativeCheck.Text = item.Initials.ToString();
                    }
                    if (item.User_Id == primeBy)
                    {
                        ddlprimedby.Text = item.Initials.ToString();
                    }
                    if (item.User_Id == Commencedby)
                    {
                        ddlCommencedBy.Text = item.Initials.ToString();
                    }
                    if (item.User_Id == completeby)
                    {
                        ddlCompleteby.Text = item.Initials.ToString();
                    }
                    if (item.User_Id == Modifiedby)
                    {
                        ddlModifiedBy.Text = item.Initials.ToString();
                    }
                    if (item.User_Id == ChangeBy)
                    {
                        ddlChangeby.Text = item.Initials.ToString();
                    }
                }
            }

        }
    }
}